<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: skyblue;
        }
    </style>
</head>

<body>
    <div>虞姬</div>
    <br />
    <div>项羽</div>
    <br />
    <div>貂蝉</div>
    <script>
        // 1. 删除事件
        let divs = document.querySelectorAll('div')
        divs[0].onclick = function () {
            console.log('123');
            this.onclick = null;
        }
        // 2. removeEventListener  删除事件  
        div[1].addEventListener('click', fn)
        function fn() {
            console.log('222');
            this.removeEventListener('click',fn)
        };
        //   3. detachEvent    ie  8   以下
        div[2].addEventListener('onclick', fn2)
        function fn() {
            console.log('333');
            this.removeEventListener('onclick',fn2)
        };
    </script>
</body>

</html>